package com.zhuiyun.project.api.sysexamine.mapper;

import com.zhuiyun.project.api.friend.entity.Friend;
import com.zhuiyun.project.api.friend.model.FriendModel;
import com.zhuiyun.project.api.sysexamine.entity.AppPhysician;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/* *
 * @Author: hui
 * @Descriprion: TODO
 * @Date: 2023/6/26 8:46
 * @return null
 * @param null
 */
@Mapper
public interface AppPhysicianMapper {



    /* *
     * @Author: hui
     * @Descriprion: 未处理的信息全查（模糊查询，分页）
     * @Date: 2023/6/26 10:17
     * @return null
     * @param null
     */
    @Select("select ph.*,us.user_name from app_physician ph JOIN app_user us where ph.del_flag = 0 and ph.audit_status = 0 and ph.doctor_name like concat('%', #{doctorName} ,'%') and ph.user_id=us.id")

    List<AppPhysician>  findAll(@Param("doctorName") String doctorName);

    /* *
     * @Author: hui
     * @Descriprion: 审核之后进行修改两张表的状态（审核通过）
     * @Date: 2023/6/26 8:47
     * @return int
     * @param id
     */
    @Update("UPDATE app_physician ph JOIN app_user us ON ph.user_id = us.id SET ph.audit_status = 1,us.user_type = 1 WHERE ph.user_id = #{id}")
    int update(@Param("id") Integer id);
    /* *
     * @Author: hui
     * @Descriprion: 审核之后进行修改两张表的状态（审核通过）
     * @Date: 2023/6/26 8:47
     * @return int
     * @param id
     */
    @Select("select * from friend WHERE del_flag=0 and user_id=#{id} or friend_id=#{id}")
    List<FriendModel> selectDoctorAll(Integer id);
    @Update("UPDATE friend SET del_flag= 1 WHERE id= #{id}")
    int updateDoctor(Integer id);
    /* *
     * @Author: hui
     * @Descriprion: 审核不通过（驳回）
     * @Date: 2023/6/26 15:17
     * @return null
     * @param null
     */
    @Update("UPDATE app_physician set audit_status = 2 where id = #{id}")
    int reject(@Param("id") Integer id);


    /* *
     * @Author: hui
     * @Descriprion: 查询所有的医师信息(医师管理全查,分页+模糊差（通过医师姓名）)
     * @Date: 2023/6/26 15:23
     * @return null
     * @param null
     */
    @Select("select * from app_physician  where del_flag = 0 and audit_status = 1 and doctor_name like concat('%', #{doctorName} ,'%') LIMIT #{page},#{size}")
    List<AppPhysician> fullPhysician(@Param("page") Integer page , @Param("size") Integer size ,@Param("doctorName") String doctorName);
}
